package com.ruoyi.web.controller;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.web.core.config.ConfigLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xiesm
 * @Description: TODO
 * @date 2025-11-07 18:19
 */
@RestController
@RequestMapping("/cp")
public class RmCookieController {
    @Autowired
    private ConfigLoader configLoader;

    @RequestMapping("/writeRmCookie")
    public String writeCookie(String cookie, String num) {
        String rmCooikePath = StrUtil.format(configLoader.getGamenamesPath() + "rm-cookie{}.txt", Integer.parseInt(num) % 400);
        // 输出粘贴板中的内容到 rm-cookie.txt
        FileUtil.writeString(cookie, rmCooikePath, "utf8");
        return cookie;
    }
}
